import { bindBusinessId, findFileList } from '@/api/upload'
export default {
  data() {
    return {
      fileList: [] // 文件上传集合
    }
  },
  methods: {
    // 业务id绑定附件
   async bindBusinessIdFile(businessId, extract) {
     let fileIds = this.fileList.map(item => item.id)
     if (!fileIds.length) {
      fileIds = []
     }
    //  只是提取附件id
     if (extract) {
        return fileIds
     }
      await bindBusinessId({
        businessId: businessId,
        fileIds: fileIds
      })
    },
    // 获取文件上传集合
    getFileList(fileList) {
      this.fileList = fileList
    },
    // 获取业务id对应文件列表
    async findFileList(businessId) {
     const { data } = await findFileList({
        businessId: businessId
      })
      return data
    }
  }
}
